using System;
using System.Collections.Generic;
using Aquasoft.Iszr.Proxy.Properties;

namespace Aquasoft.Iszr.Proxy.WebServices
{
    public interface IIszrServiceManager
    {
        string GetServiceCode(Type serviceType);
        string GetServiceUri(Type serviceType, bool? callSync = null);

        void OnBeforeCallService<TI,TO>(IszrService<TI, TO> iszrService, object input)
            where TI : class, new()
            where TO : class, new();
        void OnErrorCallService<TI, TO>(IszrService<TI, TO> iszrService, object input, Exception error)
            where TI : class, new()
            where TO : class, new();
        void OnAfterCallService<TI, TO>(IszrService<TI, TO> iszrService, object input, object result)
            where TI : class, new()
            where TO : class, new();
        void OnServiceCreated<TI,TO>(IszrService<TI, TO> iszrService)
            where TI : class, new()
            where TO : class, new();
    }

    public class IszrServiceManager 
    {
        #region Settable Singleton

        private static IIszrServiceManager _instance;
        public static IIszrServiceManager Instance
        {
            get
            {
                if (_instance == null)
                {
                    lock (typeof(IszrServiceManager))
                    {
                        if (_instance == null)
                        {
                            _instance = new DefaultIszrServiceManager();
                        }
                    }
                }
                return _instance;
            }
            set
            {
                _instance = value;
            }
        }

        private IszrServiceManager()
        {
        }

        #endregion
    }

    

}
